#pragma once
#include "message.grpc.pb.h"
#include "message.pb.h"
#include <string>
#include <mutex>
#include <memory>
#include <unordered_map>

struct ChatServer
{
    std::string host;
	std::string port;
	std::string name;
	int con_count;
};


class StatusServiceImpl final :public message::StatusServer::Service
{
public:
    StatusServiceImpl();
    ~StatusServiceImpl() = default;
    virtual ::grpc::Status GetChatServer(::grpc::ServerContext* context, 
        const ::message::GetChatServerRequest* request, ::message::GetChatServerResponse* response);
    virtual ::grpc::Status Login(::grpc::ServerContext* context, 
                const ::message::LoginRequest* request, ::message::LoginResponse* response);    

//私有方法
private:
    void InsertToken(int uid,const std::string& token);
    ChatServer getChatServer();



//私有属性
private:
    std::unordered_map<std::string,ChatServer> chat_servers_;
    int server_index_;
    std::mutex _server_mtx;
    // std::unordered_map<int,std::string> _tokens;
    // std::mutex _token_mtx;

};